<?php
//PingBuWang.Com
//Copyright (c) 2017~2099 http://www.pingbuwang.com All rights reserved.
namespace app\article\tags;

use app\article\model\ArticleCategory;
use com\EncryptUtils;
use think\template\TagLib;
use mip\Paginationm;

class TagArticleCategory extends TagLib {

    private static $modelName='app\article\model\ArticleCategory';

    protected $tags   =  [
        'get_by_id'      => ['attr' => 'value,cid', 'close' => 0],
        'get_one'      => ['attr' => 'value,where,order', 'close' => 0],
        'get_list'      => ['attr' => 'value,where,order,page,limit', 'close' => 0],
        'get_page'      => ['attr' => 'value,where,order,page,limit', 'close' => 0],
    ];

    public function tagGet_by_id($tag)
    {
        $value = $tag['value'];

        $cid = !empty($tag['cid'])?$tag['cid']:0;

        $html='<?php $'.$value.' = model("app\article\model\ArticleCategory")->getById('.$cid.'); ?> ';
        return $html;
    }

    public function tagGet_one($tag)
    {
        $value = $tag['value'];

        $where = !empty($tag['where'])?$tag['where']:'null';
        $order = !empty($tag['order'])?$tag['order']:'sort desc';

        $html='<?php $'.$value.' = model("app\article\model\ArticleCategory")->getOne('.$where.','.$order.'); ?> ';
        return $html;
    }

    public function tagGet_List($tag){

        $value = $tag['value'];
        $where = !empty($tag['where'])?$tag['where']:'null';
        $order = !empty($tag['order'])?$tag['order']:"'sort desc'";
        $page = !empty($tag['page'])?$tag['page']:1;
        $limit = !empty($tag['limit'])?$tag['limit']:100;

        $html='<?php  $'.$value.' = model("'.self::$modelName.'")->getList( '.$where.','.$order.','.$page.','.$limit.');?>';
        return $html;
    }

     
}
